import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    /* default 传给other组件的 */
    message: '',
    citycode:'',

    isPlus: false,

    /* other 传给 app 中使用 */
    city:'',
    code:'',

    unsaved:true,
    checkCityName:'',
    checkCityCode:'',
  },

  getters: {
    /* unsaved(state){
      return state.unsaved
    } */
  },

  mutations: {
    setMessage(state, payload) {
      state.message = payload
    },
    setCode(state, payload) {
      state.citycode = payload
    },
    toggleShow(state,payload) {
      state.isPlus = payload;
    },
    sendCity(state, payload){
      state.city = payload
    },
    sendCode(state, payload){
      state.code = payload
    },
    sendUnsaved(state){
      state.unsaved = false
    },
    sendcheckCityName(state, payload){
      state.checkCityName = payload
    },
    sendcheckCityCode(state, payload){
      state.checkCityCode = payload
    }
  },

  actions: {
    changeUnsaved({commit}){
      commit('sendUnsaved');
    }
  },

  modules: {
  }
})
